<?php
	/**
	*  System Navigation Menu
	* @author trungdt
	* @since Apr, 2012
	* @version 1.0
	* @copyright ABSoft Viet Nam 
	*/

	class sysnavmodule {
		function name() { return "System Navigation Module"; }
		function description() { return "Manage a set of system navigation menu"; }
		function author() { return "ABSoft.vn"; }

		function hasSources() { return false; }
		function hasContent() { return false; }
		function hasViews() { return false; }

		function supportsWorkflow() { return false; }

		function permissions($internal = "") {
			return array(
			'administrate'=>'Administrate',
			'configure'=>'Configure'
			);
		}

		function show($view,$loc = null, $title = "") {
			global $db,$user;
             
 			if (!(exponent_users_isAdmin()))
				return "";
                
			$config = $db->selectObject('sysnavmodule_config',"location_data='".serialize($loc)."'");
			if ($config == null)
				$config=sysnavmodule_config::getDefaultConfig();

			$template = new template('sysnavmodule',$view,$loc);
             //Oct 4, 2012 - son hb - add lang array
                global $langs_full;
           $template->assign("langs",$langs_full);
			$template->register_permissions(array('administrate','configure'),$loc);
			$template->output();
		}

		function deleteIn($loc) {
			global $db;
			$db->delete('sysnav',"location_data='".serialize($loc)."'");
		}

		function copyContent($oloc,$nloc) {
			foreach ($db->selectObjects('sysnav',"location_data='".serialize($oloc)."'") as $l) {
				$l->location_data = serialize($nloc);
				$db->insertObject($l,'sysnav');
			}
		}

		function searchName_() {
			return "";
		}
		
		function install(){
			global $db;
			$sql="CREATE TABLE IF NOT EXISTS `{$db->prefix}sysnavmodule_config` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `location_data` varchar(250) COLLATE utf8_unicode_ci NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=1 ;";
			$db->sql($sql);
		}
		
		function uninstall()
		{
			global $db;
			$sql="DROP TABLE `{$db->prefix}sysnavmodule_config`;";
			$db->sql($sql);
		}

	}

?>
